package com.example.second_home_work

import android.annotation.SuppressLint
import android.graphics.Color
import android.os.Bundle
import android.widget.Button
import android.widget.LinearLayout
import android.widget.Spinner
import android.widget.TextView
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat

class MainActivity : AppCompatActivity() {
    var count = 0
    val expert = syj()
    @SuppressLint("MissingInflatedId", "SetTextI18n")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_main)
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }

        val button = findViewById<Button>(R.id.button)
        button.setOnClickListener{
            val layout = findViewById<LinearLayout>(R.id.linearLayout)

            val newTextView = TextView(this)
            count++
            newTextView.text = "点击了我 $count"
            newTextView.setTextColor(Color.RED)
            layout.addView((newTextView))
        }

        val Button = findViewById<Button>(R.id.Button)
        Button.setOnClickListener{
            val spinner = findViewById<Spinner>(R.id.spinner)
            val textView = findViewById<TextView>(R.id.textView)
            textView.text = expert.getlan(spinner.selectedItem.toString())
        }
    }
}